home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr36 / pcbuse20.zip / PCBUSE.PAS < prev   
Pascal/Delphi Source File  |  1993-06-01  |  17KB  |  353 lines

  1. {----------------------------------------------------------------------------}
  2. {                                                                            }
  3. { Program:    PCBUSE.PAS                                                     }
  4. { Purpose:    Allow PCBOARD 14.0 to run Planet Busters 1.3                   }
  5. { Language:   Borland's Turbo Pascal Version 3.01                            }
  6. {                                                                            }
  7. { Author:     Carl M. Evans                                                  }
  8. {             Vervan's War Board BBS                                         }
  9. {             P.O. Box 1176, Cucamonga, CA 91730  Voice: 714-989-7824        }
  10. {             2400/1200/300 Baud (8-N-1 only)      Data: 714-989-7596        }
  11. {                                                                            }
  12. { Notice:     This program is placed in the public domain and may be         }
  13. {             freely used by anyone for any purpose.  When using this        }
  14. {             code, please give credit to the original author and to         }
  15. {             anyone who has subsequently improved or modified it.           }
  16. {                                                                            }
  17. { Narrative:  This Turbo Pascal program allows a PCBOARD 14.0 BBS to run     }
  18. {             the door program called Planet Busters (version 1.3).          }
  19. {             This routine reads the PCBOARD.SYS file and creates the        }
  20. {             special USERINFO.TXT file which the door needs to get the      }
  21. {             information it needs about the caller. Place PCBUSE.COM on     }
  22. {             your DOS path and call the program from whatever default       }
  23. {             directory that is used by your Planet Busters door program.    }
  24. {             This routine assumes certain default values for the            }
  25. {             location of the PCBOARD.SYS file as well as the name and       }
  26. {             location of the USERINFO.TXT file. The defaults are:           }
  27. {                           C:\PCB\PCBOARD.SYS                               }
  28. {                           USERINFO.TXT                                     }
  29. {             but you may override the defaults by entering the new          }
  30. {             values on the command line when you call the program.          }
  31. {             For example:                                                   }
  32. {             PCBUSE D:\PCB\PCBOARD.SYS E:\DOORS\PBUST\USERINFO.TXT          }
  33. {                                                                            }
  34. {                                                                            }
  35. { History:    Version 1.0, 11/17/87 - Original by Carl M. Evans              }
  36. {                                                                            }
  37. {             Version 2.0, 09/07/88 - Modified to handle PCBoard 14.0 door   }
  38. {                                     interface changes. This version does   }
  39. {                                     NOT support PCBoard 12.1!!!            }
  40. {                                                                            }
  41. {                                                                            }
  42. {                                                                            }
  43. {                                                                            }
  44. {                                                                            }
  45. {                                                                            }
  46. {                                                                            }
  47. {                                                                            }
  48. {                                                                            }
  49. {                                                                            }
  50. {                                                                            }
  51. {                                                                            }
  52. {                                                                            }
  53. {                                                                            }
  54. {                                                                            }
  55. {                                                                            }
  56. {                                                                            }
  57. {                                                                            }
  58. {                                                                            }
  59. {                                                                            }
  60. {----------------------------------------------------------------------------}
  61. {.PA}
  62. Program PCBUSE;
  63. {$U-}
  64. {$C-}
  65. {============================================================================}
  66. { Declarations                                                               }
  67. {============================================================================}
  68.  
  69. Const
  70.   PCB14FileDef    = 'C:\PCB\PCBOARD.SYS';
  71.   PBustFileDef    = 'USERINFO.TXT';
  72.   VersionNumber   = '2.0';
  73.  
  74. Type
  75.   Ascii2          = array[1.. 2] of char;
  76.   Ascii4          = array[1.. 4] of char;
  77.   Ascii5          = array[1.. 5] of char;
  78.   Ascii8          = array[1.. 8] of char;
  79.   Ascii12         = array[1..12] of char;
  80.   Ascii15         = array[1..15] of char;
  81.   Ascii25         = array[1..25] of char;
  82.   String2         = String[2];
  83.   String5         = String[5];
  84.   String12        = String[12];
  85.   String25        = String[25];
  86.   String80        = String[80];
  87.   FileNameType    = String[80];
  88.  
  89.   PCB14FileType   = Record             { 128 Bytes for PCBOARD version 14.0  }
  90.          Display  : Ascii2;            { Sysop's Display ON/OFF              }
  91.          Printer  : Ascii2;            { Sysop's Printer ON/OFF              }
  92.          PageBell : Ascii2;            { Sysop's Page Bell ON/OFF            }
  93.          CallAlarm: Ascii2;            { Caller Alarm ON/OFF                 }
  94.          SysopNext: Char;              { Sysop "Next On" Flag                }
  95.          ModemType: Ascii2;            { Error Correcting Modem YES/NO       }
  96.          Graphics : Char;              { Graphics Mode of Caller             }
  97.          NodeChat : Char;              { Available for Node Chat YES/NO      }
  98.          BaudOpen : Ascii5;            { Baud Rate to Open Modem at          }
  99.          BaudRate : Ascii5;            { "CONNECT" Baud Rate of Caller       }
  100.          RecordNum: Integer;           { User's Database Record Number (MKI$)}
  101.          FirstName: Ascii15;           { First Name of Caller                }
  102.          Password : Ascii12;           { Password of Caller                  }
  103.          TimeLogOn: Integer;           { Time User Logged On   (MKI$ minutes)}
  104.          TimeUsed : Integer;           { Time Used Today       (MKI$ minutes)}
  105.          LogOnStr : Ascii5;            { Time User Logged On       (HH:MM:SS)}
  106.          TimeLimit: Integer;           { Daily Time Limit      (MKI$ minutes)}
  107.          ByteLmtDL: Integer;           { Daily Download Limit  (MKI$ K-bytes)}
  108.          ConfExit : Char;              { Conference (Area) User Exited From  }
  109.          ConfFlags: Ascii5;            { Areas User Has "Joined" Today       }
  110.          ConfScan : Ascii5;            { Areas User Has Scanned for New Mail }
  111.          ConfTime : Integer;           { Area "Bonus" Time     (MKI$ minutes)}
  112.          TimeCred : Integer;           { Upload Time Credit    (MKI$ minutes)}
  113.          Language : Ascii4;            { Language Version Being Used         }
  114.          Name     : Ascii25;           { Full Name of Caller   (First & Last)}
  115.          TimeLeft : Integer;           { Session Time Remaining(MKI$ minutes)}
  116.          NodeNum  : Char;              { BBS Node Number That Caller is Using}
  117.          EventTime: Ascii5;            { Scheduled EVENT Time         (HH:MM)}
  118.          EventFlag: Ascii2;            { Is EVENT Time Active?               }
  119.          EventMove: Ascii2;            { Delay EVENT Until User Logs Off?    }
  120.          MsgRecall: Ascii4;            { "Memorized" Message Number    (MKS$)}
  121.          ComPortID: Char;              { Com Port Number (0, 1, 2)           }
  122.          Reserved : Ascii2;            { Reserved for Future Use             }
  123.        end;
  124.  
  125. Var
  126. { Variables used for Planet Busters USERINFO.TXT                             }
  127.   UserName        : String25;          { PCBoard limits UserName to 25 bytes }
  128.   BaudRate        : String5;           { Caller's baud rate                  }
  129.   TimeLeftToday   : Integer;           { PCBoard (mins) => PBust (seconds)   }
  130.   DataBits        : Char;              { 7 or 8                              }
  131.  
  132. { Variables used to define disk files                                        }
  133.   PCB14File       : File of PCB14FileType;
  134.   PCB14FileName   : FileNameType;
  135.   PCB14Data       : PCB14FileType;
  136.   PBustFile       : Text;
  137.   PBustFileName   : FileNameType;
  138.  
  139. { Miscellaneous Variables                                                    }
  140.   ErrorCode       : Integer;
  141.  
  142. {============================================================================}
  143. { Function to "pad" a date/time number to a 2-byte string                    }
  144. {============================================================================}
  145. Function Pad2(NumS:String2) :String2;
  146.  
  147. Begin { Pad2 }
  148.   Case Length(NumS) of
  149.     0            : Pad2 := '00';
  150.     1            : Pad2 := '0' + NumS;
  151.     2            : Pad2 := NumS;
  152.   Else             Begin
  153.                      Pad2[1] := NumS[1];
  154.                      Pad2[2] := NumS[2];
  155.                    End;
  156.   End; {endcase}
  157. End;  { Pad2  }
  158. {============================================================================}
  159. { Function to trim leading blanks from a string                              }
  160. {============================================================================}
  161. Function TrimL(InpStr: String80): String80;
  162.  
  163. Var
  164.   I,
  165.   Len            : Integer;
  166.  
  167. Begin { TrimL }
  168.   Len := Length(InpStr);
  169.   I := 1;
  170.   While (I <= Len) and (InpStr[I] = ' ') do
  171.     I := I + 1;
  172.     TrimL := Copy(InpStr,I,Len-I+1)
  173. End;  { TrimL }
  174.  
  175. {============================================================================}
  176. { Function to trim trailing blanks from a string                             }
  177. {============================================================================}
  178. Function TrimR(InpStr: String80): String80;
  179.  
  180. Var
  181.   I              : Integer;
  182.  
  183. Begin { TrimR }
  184.   I := Length(InpStr);
  185.   While (I >= 1) and (InpStr[I] = ' ') do
  186.     I := I - 1;
  187.     TrimR := Copy(InpStr,1,I)
  188. End;  { TrimR }
  189.  
  190. {============================================================================}
  191. { Function to convert a string to upper case characters                      }
  192. {============================================================================}
  193. Function UpperCase(InpStr: String80): String80;
  194.  
  195. Var
  196.   I : Integer;
  197.  
  198. Begin { UpperCase }
  199.    For I := 1 to Length(InpStr) do
  200.       UpperCase[I] := UpCase(InpStr[I]);
  201.    UpperCase[0] := InpStr[0]
  202. End;  { UpperCase }
  203.  
  204. {============================================================================}
  205. { Procedure to make an annoying BEEP sound                                   }
  206. {============================================================================}
  207. Procedure Beep;
  208.  
  209. Begin { Beep }
  210.   Sound(450);
  211.   Delay(500);
  212.   NoSound;
  213. End;  { Beep }
  214.  
  215. {============================================================================}
  216. { Procedure to display command line syntax for sysop when error occurs       }
  217. {============================================================================}
  218. Procedure FatalError;
  219.  
  220. Begin { FatalError }
  221.   Beep;
  222.   Writeln(' ');
  223.   Writeln('FIRST PARAMETER (optional) -');
  224.   Writeln(' The default is:  C:\PCB\PCBOARD.SYS');
  225.   Writeln(' If you wish to override the default path for PCBOARD.SYS,');
  226.   Writeln(' then specify a new path as the first parameter.');
  227.   Writeln(' NOTE: Include the file name with the path.');
  228.   Writeln(' ');
  229.   Writeln('SECOND PARAMETER (optional) -');
  230.   Writeln(' The default is:  USERINFO.TXT');
  231.   Writeln(' If you wish to override the default path for USERINFO.TXT,');
  232.   Writeln(' then specify a new path as the second parameter.');
  233.   Writeln(' NOTE: Include the file name with the path.');
  234.   Writeln(' ');
  235.   Writeln('For Example:');
  236.   Writeln('PCBUSE D:\PCB\PCBOARD.SYS E:\DOORS\PBUST\USERINFO.TXT');
  237.   HALT(1);
  238. End;  { FatalError }
  239.  
  240. {============================================================================}
  241. { Procedure to parse the command line                                        }
  242. {============================================================================}
  243. Procedure ParseCommandLine;
  244.  
  245. Begin { ParseCommandLine }
  246.   If ParamCount > 0 then begin
  247.     PCB14FileName   := ParamStr(1);
  248.     PCB14FileName   := TrimL(PCB14FileName);
  249.     PCB14FileName   := TrimR(PCB14FileName);
  250.     PCB14FileName   := UpperCase(PCB14FileName);
  251.   End else begin
  252.     PCB14FileName   := PCB14FileDef;
  253.   End; {endif}
  254.   Writeln(' ');
  255.   Writeln('INPUT FILESPEC = ' + PCB14FileName);
  256.  
  257.   If ParamCount > 1 then begin
  258.     PBustFileName   := ParamStr(2);
  259.     PBustFileName   := TrimL(PBustFileName);
  260.     PBustFileName   := TrimR(PBustFileName);
  261.     PBustFileName   := UpperCase(PBustFileName);
  262.   End else begin
  263.     PBustFileName   := PBustFileDef;
  264.   End; {endif}
  265. End;  { ParseCommandLine }
  266.  
  267. {============================================================================}
  268. { Procedure to read the PCBOARD.SYS file                                     }
  269. {============================================================================}
  270. Procedure ReadPCBoardSysFile;
  271.  
  272. Begin { ReadPCBoardSysFile }
  273.   Assign(PCB14File,PCB14FileName);
  274.   {$I-} Reset(PCB14File); {$I+}
  275.   ErrorCode := IOresult;
  276.   If ErrorCode <> 0 then begin
  277.     Close(PCB14File);
  278.     Writeln(' ');
  279.     Writeln('ERROR: Could not find PCBOARD.SYS');
  280.     FatalError;
  281.   End; {endif}
  282.   Read(PCB14File,PCB14Data);
  283.   Close(PCB14File);
  284. End;  { ReadPCBoardSysFile }
  285.  
  286. {============================================================================}
  287. { Procedure to translate PCBOARD.SYS to USERINFO.TXT                         }
  288. {============================================================================}
  289. Procedure TranslateUserData;
  290.  
  291. Var
  292.   I              : Integer;
  293.   Temp           : String5;
  294.  
  295. Begin { TranslateUserData }
  296.   UserName       := TrimR(PCB14Data.Name);
  297.  
  298.   For I := 1 to 5 do begin
  299.     Temp[I] := PCB14Data.BaudRate[I];
  300.   End;
  301.   BaudRate := Temp;
  302.  
  303.   If PCB14Data.Graphics = '7' then begin
  304.     DataBits     := '7';
  305.   End else begin
  306.     DataBits     := '8';
  307.   End; {endif}
  308.  
  309.   TimeLeftToday  := 60*PCB14Data.TimeLeft;
  310. End;  { TranslateUserData }
  311.  
  312. {============================================================================}
  313. { Procedure to create USERINFO.TXT file                                      }
  314. {============================================================================}
  315. Procedure WritePBustFile;
  316.  
  317. Begin { WritePBustFile }
  318.   Assign(PBustFile,PBustFileName);
  319.   {$I-} Rewrite(PBustFile); {$I+}
  320.   ErrorCode := IOresult;
  321.   If ErrorCode <> 0 then begin
  322.     Writeln(' ');
  323.     Writeln('ERROR: Illegal file name specified for output file');
  324.     Close(PBustFile);
  325.     FatalError;
  326.   End; {endif}
  327.   Writeln(PBustfile,UserName);       { Caller's logon name                 }
  328.   Writeln(PBustfile,BaudRate);       { Caller's logon baud rate            }
  329.   Writeln(PBustfile,DataBits);       { Com setting: 7 or 8 databits/word   }
  330.   Writeln(PBustfile,TimeLeftToday);  { Caller's remaining time on the BBS  }
  331.   Close(PBustFile);
  332. End;  { WritePBustFile }
  333.  
  334. {============================================================================}
  335. { Main Program                                                               }
  336. {============================================================================}
  337.  
  338. Begin
  339.   Writeln('');
  340.   Writeln('PCBUSE version ' + VersionNumber +
  341.    ' Run Planet Busters Door on PCBOARD 14.0');
  342.   Writeln('');
  343.   Writeln('[ A PCBoard 14.0 utility from Vervan' + Chr(39) +
  344.     's War Board (714) 989-7596 ]');
  345.   Writeln('');
  346.   ParseCommandLine;
  347.   ReadPCBoardSysFile;
  348.   TranslateUserData;
  349.   WritePBustFile;
  350. End.
  351.  
  352. {===[ END OF PROGRAM ]=======================================================}
  353.